﻿using System;
using System.Data.Entity;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Arquitetura.Architectural.Model
{
    public static class ObjectContextHelper
    {
        #region Método(s)
        private static void DetachAll(this ObjectContext objectContext, IList<EntityObject> entityObjectList)
        {
            foreach (EntityObject entityObject in entityObjectList)
            {
                objectContext.Detach(entityObject);
            }
        }
        
        public static ObjectQuery<TSource> Include<TSource>(this ObjectQuery<TSource> objectQuery, IEnumerable<string> entityAttributesInclusion)
        {
            foreach (string entityToInclude in entityAttributesInclusion)
            {
                objectQuery = objectQuery.Include(entityToInclude);
            }
            return objectQuery;            
        }
        #endregion Método(s)
    }
}
